<template>
   <div>
    <h1>查看Vue的关键帧动画效果</h1>
    <button @click="isShow = !isShow">控制元素的显示和隐藏</button>
    <transition name="one">
      <div class="text" v-show="isShow">我是动画元素</div>
    </transition>
  </div>
</template>

<script>
export default {
  name: "Anim",
  data() {
    return {
      isShow: true,
    };
  },
};

</script>

<style scoped>
.text {
  width: 200px;
  height: 50px;
  background: yellowgreen;
  font-size: 18px;
  text-align: center;
  line-height: 50px;
}

@keyframes one {
  0% {
    transform: translate(300px, 0px);
    opacity: 0;
  }
  30% {
    transform: translate(200px, 50px);
  }
  70% {
    transform: translate(100px, -50px);
  }
  100% {
    transform: translate(0px, 0px);
  }
}

.one-enter-active {
  animation: one 1s linear;
}

.one-leave-active {
  animation: one 1s linear reverse;
}
</style>